
//商品编辑
	public function edit(){
		$gid=Q('get.gid',0,'intval');
		if(IS_POST){
			if(!$this->model->edit()) View::error($this->model->getError());
			View::success('编辑成功');
		}
		//1获得商品数据
		$goodsData=$this->model->where("gid='{$gid}'")->find('cate_cid');
		View::with('goodsData',$goodsData);
		//2处理所属分类
		$GoodeCate=new \Common\Model\Cate;
		$cateData = Data::tree($GoodeCate->get(),'cname');
//		p($cateData);
		View::with('cateData',$cateData);
		//3处理所属品牌
		$GoodsBand=new \Common\Model\Band;
		$bandData=$GoodsBand->get();
		View::with('bandData',$bandData);
		//4获得商品旧数据
		$oldData=$this->model->where("gid='{$gid}'")->find();
		View::with('oldData',$oldData);
//		p($oldData);
		//5获得商品详细数据
		$goodsDetail=new \Common\Model\Detail;
		$DetailData=$goodsDetail->where("goods_gid='{$gid}'")->find();
		$DetailData['dpic']=explode('|', $DetailData['dpic']);
		View::with('DetailData',$DetailData);
//		p($DetailData);
		//6获得商品属性表的数据
		$goodsattr=new \Common\Model\Goodsattr;
		$goodsattrData=$goodsattr->join('typeattr','typeattr_taid','=','taid')->where("goods_gid='{$gid}'")->get();
		array_walk($goodsattrData,function(&$v,$k){
			if(!empty($v['tavalue'])){
				//把字符串转化为数组
				$v['tavalue']=explode('|', $v['tavalue']);
			}
		});
		View::with('goodsattrData',$goodsattrData);
//		p($goodsattrData);
	    View::make();
	}








<p class="btn btn-primary">
								商品属性
							</p>
							<table class="table table-bordered table-hover" id='attr' class="info">
								
								{{foreach from='$data' value="$v"}}
									
										{{if value="$v['attributetype']==0"}}
										<tr class="info">
									<td>{{$v['aname']}}</td>
									<td>
										{{if value="in_array($v['navalue'],$v['avalue'])"}}
										<select name="navalue[{{$v['aid']}}]" >
											{{foreach from="$v['avalue']" value="$b"}}
											<option value="{{$b}}">{{$b}}</option>
											{{endforeach}}
										</select>
										{{endif}}
										</td></tr>
										{{endif}}							
								
								{{endforeach}}
								
							</table>
							<p class="btn btn-primary">
								商品规格
							</p>
							<table class="table table-bordered table-hover" id='spec'>
								
								{{foreach from='$data' value="$v"}}
									
										{{if value="$v['attributetype']==1"}}
										<tr class="info">
									<td>{{$v['aname']}}</td>
									<td>
										{{if value="in_array($v['navalue'],$v['avalue'])"}}
										<select name="extra[{{$v['aid']}}][value][]">
											{{foreach from='$v["avalue"]'  value="$b"}}
											<option value="">{{$b}}</option>
											{{endforeach}}
										</select>
										{{endif}}
										</td>
										<td>附加价格：<input type="text" name="extra[{{$v['aid']}}][extra][]" id="" /></td>
								<td><span class="btn btn-success add-spec">增加规格</span></td>
										</tr>
										
										{{endif}}
									
								
								{{endforeach}}
